package com.codeczx.customviewdemo.limitedscroller;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.codeczx.customviewdemo.R;

import java.util.List;

/**
 * Created by codeczx on 2017/9/21.
 */

public class LimitedAdapter implements LimitedScroller.LimitedAdapter {

    private Context mContext;
    private List<String> mData;

    public LimitedAdapter(Context context, List<String> list) {
        mContext = context;
        mData = list;
    }

    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }

    @Override
    public View getView(int index) {
        View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_scroller, null, false);
        TextView tv = (TextView) itemView.findViewById(R.id.tv_content);
        tv.setText(mData.get(index));
        itemView.setTag(mData.get(index));
        return itemView;
    }
}
